package com.alibaba.citrus.ots.sales.plan.facade.service.setting.contract;

import com.alibaba.citrus.ots.common.annotation.FacadeInvoker;
import com.alibaba.citrus.ots.sales.plan.api.setting.contract.DepartmentContractRedLineWriteService;
import com.alibaba.citrus.ots.sales.plan.functions.departmentcontractredline.DepartmentContractRedLineEntity;
import com.alibaba.citrus.ots.sales.plan.repository.DepartmentContractRedLineRepository;
import com.alibaba.citrus.ots.sales.plan.sdo.DepartmentContractRedLineSDO;
import com.alibaba.cz.base.tool.result.Result;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author wangyibing
 */
@Component
public class DepartmentContractRedLineWriteServiceImpl implements DepartmentContractRedLineWriteService {

    @Resource
    private DepartmentContractRedLineRepository departmentContractRedLineRepository;

    @Override
    @FacadeInvoker
    public Result<String> createDepartmentContractRedLine(DepartmentContractRedLineSDO redLineSDO) {
        DepartmentContractRedLineEntity redLineEntity = DepartmentContractRedLineEntity.of(redLineSDO);
        String lastInsertId = redLineEntity.doCreate();
        return Result.success(lastInsertId);
    }

    @Override
    @FacadeInvoker
    public Result<Boolean> batchUpdateRedCount() {
        return departmentContractRedLineRepository.batchUpdateRedCount();
    }
}
